package com.hakim.wfb.customer.service.impl;

import com.hakim.wfb.bean.CreditPoint;
import com.hakim.wfb.biz.CreditPointBiz;
import com.hakim.wfb.customer.result.trans.CreditPointView;
import com.hakim.wfb.customer.service.CreditPointService;
import com.hakim.wfb.customer.service.convert.CreditPointDtv;
import com.hkfs.fundamental.api.data.ObjectResultEx;
import com.hkfs.fundamental.api.data.ResultEx;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * Created by Administrator on 2017/7/1.
 */
@Service("creditPointService")
public class CreditPointServiceImpl implements CreditPointService {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private CreditPointBiz creditPointBiz;

    @Override
    public ObjectResultEx<CreditPointView> getCreditPoint(String user) {

        ObjectResultEx<CreditPointView> resultEx = new ObjectResultEx<>();
        if (user == null || user.equals(""))
            return resultEx.makeFailedResult();

        try {
            CreditPoint creditPoint = creditPointBiz.getCreditPoint(user);
            if (creditPoint != null) {
                CreditPointView view = CreditPointDtv.convert(creditPoint);
                resultEx.setDataObject(view);
                return resultEx.makeSuccessResult();
            } else {
                resultEx.setDataObject(null);
                return resultEx.makeFailedResult();
            }
        } catch (Exception e) {
            return resultEx.makeFailedResult();
        }


    }
}
